<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>哈哈</h1>

<div id="app" style="width: 500px;height: 300px;background-color: gainsboro">

</div>

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>

    const http = axios.create({
        baseURL: 'http://localhost:8080/',
        timeout: 10000000,
        responseType: 'stream',
        onDownloadProgress: function (progressEvent) {
            // 处理原生进度事件
            // console.log("progressEvent->",progressEvent.event.currentTarget.responseText);
            document.getElementById("app").innerHTML =
                progressEvent.event.currentTarget.responseText
            // responseText 就是sse的完整数据
        },
    });

    http.get('/sse')
        .then(function (response) {
            // 处理成功情况
            console.log(response);
        })
        .catch(function (error) {
            // 处理错误情况
            console.log(error);
        })
        .finally(function () {
            // 总是会执行
        });
</script>

</body>
</html>